package com.itheima.health.controller.admin;


import com.itheima.health.common.MessageConst;
import com.itheima.health.pojo.ReportData;
import com.itheima.health.result.Result;
import com.itheima.health.service.ReportService;
import com.itheima.health.vo.MemberVO;
import com.itheima.health.vo.SetMealReportVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletResponse;


@RestController
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private ReportService reportService;

    @GetMapping("/getMemberReport")
    public Result getMemberReport() {
        MemberVO memberVO = reportService.getMemberReport();
        return new Result(true, MessageConst.ACTION_SUCCESS, memberVO);
    }

    @GetMapping("/getSetmealReport")
    public Result getSetmealReport() {
        SetMealReportVO setMealReportVO = reportService.getSetmealReport();
        return new Result(true, MessageConst.GET_SETMEAL_COUNT_REPORT_SUCCESS, setMealReportVO);
    }

    @GetMapping("/getBusinessReportData")
    public Result getBusinessReportData() {

      ReportData reportData =  reportService.getBusinessReportData();
      return  new Result(true,MessageConst.GET_BUSINESS_REPORT_SUCCESS,reportData);

    }
    @GetMapping("/exportBusinessReport")
    public void exportBusinessReport(HttpServletResponse response){
        reportService.exportBusinessReport(response);
    }


}
